package yi.commons.net.http;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

/**
 * Http的配置
 */
class HttpRequestConfig {
    /* ---------------------- */
    /*         URL相关属性      */
    /* ---------------------- */

    private String url;
    private String host;
    private int port;
    private String path;
    private String schema;

    private String loadBalanceStrategy;

    private boolean useNewThread = false;

    private Map<String, String> headers = new HashMap<>();

    private Map<String, ?> parameters = new HashMap<>();

    private Map<String, ?> body = new HashMap<>();

    private String bodyStr = "";

    private Map<String, ?> uploadFiles = new HashMap<>();

    private int maxBodySize;

    private String encoding = "UTF-8";

    // https 配置

    private boolean isHttps = false;

    private boolean enableHostVerify = false;

    // 日志配置
    private boolean enableLog = false;
    private Consumer preLogConsumer;
    private Consumer postLogConsumer;
    private int maxLogSize = 0;

    // 超时配置
    private int connectTimeout = 5000;

    private int sendTimeout = 5000;

    private int receiveTimeout = 15000;

    // 响应事件

    // 是否开启Mock功能
    private boolean enableMock = false;

    private Http buildHttp() {
        return new Http();
    }

    public HttpResponse get() {

        return buildHttp().get();
    }

    public HttpResponse post() {

        return buildHttp().post();
    }

    public HttpResponse put() {

        return buildHttp().put();
    }

    public HttpResponse delete() {

        return buildHttp().delete();
    }

    public HttpResponse head() {

        return buildHttp().head();
    }

    public HttpResponse options() {

        return buildHttp().options();
    }

}